package cn.harry.modular.news.controller;

import cn.harry.common.api.R;
import cn.harry.modular.news.service.HomeService;
import cn.harry.modular.news.vo.CountVO;
import cn.harry.modular.news.vo.EchartsOptionVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author harry
 * @公众号 Harry技术
 */

@Tag(name = "首页")
@RestController
@RequestMapping("/home")
@RequiredArgsConstructor
public class HomeController {
    private final HomeService homeService;

    @Operation(summary = "首页计数")
    @GetMapping("/counts")
    public R<List<CountVO>> counts() {
        List<CountVO> list = homeService.counts();
        return R.success(list);
    }

//    用户回答统计
    @Operation(summary = "用户回答统计")
    @GetMapping("/userAnswerCounts")
    public R<EchartsOptionVO> userAnswerCounts() {
        EchartsOptionVO list = homeService.userAnswerCounts();
        return R.success(list);
    }

//   新闻分类统计
    @Operation(summary = "新闻分类统计")
    @GetMapping("/newsCategoryCounts")
    public R<List<CountVO>> newsCategoryCounts() {
        List<CountVO> list = homeService.newsCategoryCounts();
        return R.success(list);
    }
}
